<!-- OGN -->
<?php 
require_once ("config/web.init.php");
require_once ("config/web.config.php");
require_once ("base_init.php");
	
// INPUTS
$userX = "";
$passX1 = "";
$passX2 = "";
$fullName = "";
$inviteCode = "";
// ERROR
$errMsg = "";
$goodMsg = "";

// FORM SUBMISSION CHECK AND PROCESSING
if (Security::inputExists()) {
	$userX = Security::inputRead("UserName");
	$passX1 = Security::inputRead("Password");
	$passX2 = Security::inputRead("ConfirmPassword");
	$inviteCode = Security::inputRead("InviteCode");
	$fullName = Security::inputRead("FullName");
	//print "USERNAME: $userX<br/>PASS1: $passX1, PASS2: $passX2<br/>INVITECODE: $inviteCode<br/>FULLNAME: $fullName<br/>";
	$validate = new UserRegnValidator();
		$validation = $validate->check($_POST, array(
			'UserName' => array(
				'required' => true,
				'min' => 2,
				'max' => 100,
				'email' => 'users'),
			'Password' => array(
				'required' => true,
				'min' => 6),
			'ConfirmPassword' => array(
				'required' => true,
				'matches' => 'Password'),
			'InviteCode' => array(
				'required' => true,
				'min' => 6,
				'default' => '098765'),
			'FullName' => array(
				'required' => false,
				'min' => 2,
				'max' => 50)
		));

		if($validation->passed()) {
			$UserMgr = new UserMgr();
			print $UserMgr->createUser($userX, $passX1, $fullName);
			$goodMsg = "Successfully created User Account. Please follow the next steps of Registration.";
			
		} else {
			foreach($validate->errors() as $error) {
				$errMsg .= "ERR: $error<br/>";
			}
		}
	
} 


?>


<?php

$pageTitle = "OGN: SignUp";
?>
<html>
<head>
<title><?php echo $pageTitle;?></title>

</head>
<body>

<!-- Main:Table -->
<table border='0' cellspacing='0' cellpadding='0' height='100%' width='100%' valign='center' align='center'>
<!-- Header -->
<tr>
	<td colspan='1' valign='' align='left' width='10%' height='10%'></td>
	<td colspan='1' valign='' align='left' width='80%' height='10%'></td>
	<td colspan='1' valign='' align='left' width='10%' height='10%'></td>
</tr>
<tr>
	<td colspan='1' valign='' align='left' width='10%' height='80%'></td>
	<td colspan='1' valign='center' align='left' width='80%' height='80%'>
	<!-- Center:Table -->
			<table border='0' cellspacing='0' cellpadding='0' height='100%' width='100%' valign='center' align='center'>
				<!-- Header -->
				<tr>
					<td colspan='1' valign='' align='left' width='10%' height='10%'></td>
					<td colspan='1' valign='' align='left' width='80%' height='10%'></td>
					<td colspan='1' valign='' align='left' width='10%' height='10%'></td>
				</tr>
				<tr>
					<td colspan='1' valign='' align='left' width='10%' height='80%'></td>
					<td colspan='1' valign='' align='left' width='80%' height='80%'>
						<!-- Login:Table -->
						<table border='0' cellspacing='0' cellpadding='0' height='100%' width='100%' valign='center' align='center'>
						<!-- Header -->
						<tr>
							<td colspan='1' valign='' align='left' width='23%' height='10%'></td>
							<td colspan='1' valign='' align='left' width='2%' height='10%'></td>
							<td colspan='1' valign='' align='left' width='50%' height='10%'></td>
							<td colspan='1' valign='' align='left' width='25%' height='10%'></td>
						</tr>
						<tr>
							<td colspan='1' valign='' align='left' width='23%' height='10%'></td>
							<td colspan='1' valign='' align='left' width='2%' height='10%'></td>
							<td colspan='1' valign='' align='left' width='50%' height='80%'>
								<div class="container">
								  <div class="signUp">
									<h3><?php echo $loginTitle;?> :: Sign Up</h3>
									<font color='red'><?php echo $errMsg;?></font>
									<font color='green'><?php echo $goodMsg;?></font>
									  <form name='signUp' method='post' action=''>
									  <p><input type="text" size='50' maxsize='200' name="UserName" value="<?php echo $userX;?>" placeholder="Email"></p>
									  <p><input type="password" name="Password" value="<?php echo $passX1;?>" placeholder="Password"></p>
									  <p><input type="password" name="ConfirmPassword" value="<?php echo $passX2?>" placeholder="Password Again"></p>
									  <p><input type="password" name="InviteCode" value="<?php echo $inviteCode?>" placeholder="Invitation Code"></p>
									  <p><input type="text" name="FullName" size='50' maxsize='50' value="<?php echo $fullName?>" placeholder="Full Name"></p>
									  <p class="submit"><input type="submit" name="submit" value="SignUp"> &nbsp;&nbsp;&nbsp;<input type="reset" name="reset" value="Clear"></p>
									</form>
								  </div>
								 
								  <div class="newuser-help">
									<p>Already an User <a href="index.php">Login</a>.</p>
								  </div>
								  <div class="login-help">
									<p>Forgot your password? <a href="forgotPassword.php">Click here to reset...</a>.</p>
								  </div>
								</div>
							</td>
							<td colspan='1' valign='' align='left' width='25%' height='80%'></td>
						</tr>
						<!-- Footer -->
						<tr>
							<td colspan='1' valign='' align='left' width='23%' height='10%'></td>
							<td colspan='1' valign='' align='left' width='2%' height='10%'></td>
							<td colspan='1' valign='' align='left' width='50%' height='10%'></td>
							<td colspan='1' valign='' align='left' width='25%' height='10%'></td>
						</tr>
						</table>
						<!-- Login:Table -->
					</td>
					<td colspan='1' valign='' align='left' width='10%' height='80%'></td>
				</tr>
				<!-- Footer -->
				<tr>
					<td colspan='1' valign='' align='left' width='10%' height='10%'></td>
					<td colspan='1' valign='' align='left' width='80%' height='10%'></td>
					<td colspan='1' valign='' align='left' width='10%' height='10%'></td>
				</tr>
				</table>
			<!-- Center:Table -->
			</td>
			<td colspan='1' valign='' align='left' width='10%' height='80%'></td>
		</tr>
		
		
<!-- Footer -->
<tr>
	<td colspan='1' valign='' align='left' width='10%' height='10%'></td>
	<td colspan='1' valign='' align='left' width='80%' height='10%'>
	<?php include_once("footer.php"); ?>
	</td>
	<td colspan='1' valign='' align='left' width='10%' height='10%'></td>
</tr>
</table>
<!-- Main:Table -->
</body>
</html>
